package adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.newxlmedical.R;

import java.util.List;

import beans.TakeAndReturnBean;
import butterknife.BindView;
import custom.BaseRecyclerAdapter;

/**
 * Created by Administrator on 2018/5/9.
 */

public class TakeAndReturnAdapter extends BaseRecyclerAdapter<TakeAndReturnAdapter.TakeViewHolder> {

    private Context mContext;
    private LayoutInflater inflater;
    private List<TakeAndReturnBean> list;

    public TakeAndReturnAdapter(Context mContext, List<TakeAndReturnBean> list) {
        this.mContext = mContext;
        this.list = list;
        inflater = LayoutInflater.from(mContext);
    }

    @Override
    public TakeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        TakeViewHolder viewHolder = new TakeViewHolder(inflater.inflate(R.layout.adapter_take_and_return, parent, false));
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(TakeViewHolder viewHolder, int position) {
        TakeAndReturnBean bean = list.get(position);
        viewHolder.tvCabinetNumber.setText(bean.getCabinetNumber());
        viewHolder.tvGoodsName.setText(bean.getGoodsName());
        viewHolder.tvSpecification.setText(bean.getSpecification());
        viewHolder.tvSupplier.setText(bean.getSupplier());
        viewHolder.tvNumber.setText(bean.getNumber());
        viewHolder.tvUnit.setText(bean.getUnit());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class TakeViewHolder extends BaseRecyclerAdapter.BaseViewHolder {
        @BindView(R.id.tv_adapter_take_cabinet_number)
        TextView tvCabinetNumber;
        @BindView(R.id.tv_adapter_take_goods_name)
        TextView tvGoodsName;
        @BindView(R.id.tv_adapter_take_specification)
        TextView tvSpecification;
        @BindView(R.id.tv_adapter_take_supplier)
        TextView tvSupplier;
        @BindView(R.id.tv_adapter_take_number)
        TextView tvNumber;
        @BindView(R.id.tv_adapter_take_unit)
        TextView tvUnit;

        public TakeViewHolder(View itemView) {
            super(itemView);
        }
    }
}
